package views.inventory;

import java.awt.event.ActionListener;

import javax.swing.JPanel;
import javax.swing.SpringLayout;
import javax.swing.JTextField;
import javax.swing.JSeparator;
import javax.swing.JLabel;
import javax.swing.JTextArea;
import javax.swing.JButton;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import javax.swing.border.BevelBorder;
import javax.swing.UIManager;

import uiframework.NumericField;
import uiframework.StringField;

public class AddNewSeller extends JPanel{
	private StringField tName;
	private NumericField tPhone;
	private JTextField tEmail;
	private JTextArea textAreaAdress;
	private JButton btnSave;
	private JButton btnDelete;
	private JButton btnUpdate;
	private JButton btnBack;
	private JButton btnSearch;
	private JButton btnForward;
	private JButton btnExit;
	private JButton btnClear;
	private JButton[] butgroup=new JButton[8];
	private JLabel lblSellerid;
	private JLabel lblSellerIdlbl;
	private JLabel lblXyzgmailcom;

	public AddNewSeller() 
	{
		SpringLayout springLayout = new SpringLayout();
		setLayout(springLayout);
		setPreferredSize(new Dimension(350, 550));
		setSize(350, 550);
		this.setMinimumSize(new Dimension(350, 550));
		this.setBackground(new Color(239,239,239));
		this.setMaximumSize(new Dimension(350, 550));
		this.setBackground(new Color(239,239,239));
		
		
		JLabel lblName = new JLabel("NAME:");
		springLayout.putConstraint(SpringLayout.NORTH, lblName, 30, SpringLayout.NORTH, this);
		springLayout.putConstraint(SpringLayout.WEST, lblName, 30, SpringLayout.WEST, this);
		add(lblName);
		
		tName = new StringField();
		springLayout.putConstraint(SpringLayout.NORTH,tName, 6, SpringLayout.SOUTH, lblName);
		springLayout.putConstraint(SpringLayout.WEST, tName, 30, SpringLayout.WEST, this);	
		add(tName);
		tName.setPreferredSize(new Dimension(250, 23));
		
		JLabel lblPhone = new JLabel("PHONE:");
		springLayout.putConstraint(SpringLayout.NORTH, lblPhone, 30, SpringLayout.SOUTH, tName);
		springLayout.putConstraint(SpringLayout.WEST, lblPhone, 30, SpringLayout.WEST, this);
		add(lblPhone);

		tPhone = new NumericField();
		springLayout.putConstraint(SpringLayout.NORTH, tPhone, 6, SpringLayout.SOUTH, lblPhone);
		springLayout.putConstraint(SpringLayout.WEST, tPhone, 30, SpringLayout.WEST,this);
		tPhone.setFont(new Font("Tahoma", Font.PLAIN, 15));
		add(tPhone);
		tPhone.setPreferredSize(new Dimension(250, 23));
		
		JLabel lblEmail = new JLabel("EMAIL:");
		springLayout.putConstraint(SpringLayout.NORTH, lblEmail, 30, SpringLayout.SOUTH, tPhone);
		springLayout.putConstraint(SpringLayout.WEST, lblEmail, 30, SpringLayout.WEST, this);
		add(lblEmail);
		

		tEmail = new JTextField();
		springLayout.putConstraint(SpringLayout.NORTH, tEmail, 6, SpringLayout.SOUTH, lblEmail);
		springLayout.putConstraint(SpringLayout.WEST, tEmail, 30, SpringLayout.WEST, this);
		tEmail.setFont(new Font("Tahoma", Font.PLAIN, 15));
		add(tEmail);
		tEmail.setPreferredSize(new Dimension(250, 23));
		
		
		JLabel lblAddress = new JLabel("ADDRESS:");
		springLayout.putConstraint(SpringLayout.NORTH, lblAddress, 30, SpringLayout.SOUTH, tEmail);
		springLayout.putConstraint(SpringLayout.WEST, lblAddress, 30, SpringLayout.WEST, this);
		add(lblAddress);
		
		textAreaAdress = new JTextArea();
		textAreaAdress.setBackground(Color.PINK);
		springLayout.putConstraint(SpringLayout.NORTH, textAreaAdress, 6, SpringLayout.SOUTH, lblAddress);
		springLayout.putConstraint(SpringLayout.WEST, textAreaAdress, 30, SpringLayout.WEST, this);
		add(textAreaAdress);
		textAreaAdress.setPreferredSize(new Dimension(250, 65));
		
		JPanel panel=new JPanel();
		springLayout.putConstraint(SpringLayout.NORTH, panel, 25, SpringLayout.SOUTH, textAreaAdress);
		springLayout.putConstraint(SpringLayout.SOUTH, panel, 132, SpringLayout.SOUTH, textAreaAdress);
		springLayout.putConstraint(SpringLayout.EAST, panel, -30, SpringLayout.EAST, this);
		springLayout.putConstraint(SpringLayout.HORIZONTAL_CENTER, panel, 0, SpringLayout.HORIZONTAL_CENTER, this);
		add(panel);
		panel.setPreferredSize(new Dimension(250, 65));
		GridLayout g=new GridLayout(3, 3,2,2);
		panel.setLayout(g);
		
		btnSave = new JButton("SAVE");
		butgroup[0]=btnSave;
		btnSave.setActionCommand("SAVE");
		panel.add(btnSave);
		
		btnDelete = new JButton("MARK INACTIVE");
		btnDelete.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
			}
		});
		butgroup[1]=btnDelete;
		btnDelete.setActionCommand("MARK INACTIVE");
		panel.add(btnDelete);
		
		btnUpdate = new JButton("UPDATE");
		butgroup[2]=btnUpdate;
		btnUpdate.setActionCommand("UPDATE");
		panel.add(btnUpdate);
		
		btnBack = new JButton("<<");
		panel.add(btnBack);
		butgroup[3]=btnBack;
		btnBack.setActionCommand("<<");
		
		btnSearch = new JButton("SEARCH");
		panel.add(btnSearch);
		butgroup[4]=btnSearch;
		btnSearch.setActionCommand("SEARCH");
		
		btnForward = new JButton(">>");
		panel.add(btnForward);
		butgroup[5]=btnForward;
		btnForward.setActionCommand(">>");
		
		JButton btnNewButton_5 = new JButton("");
		panel.add(btnNewButton_5);
		btnNewButton_5.setVisible(false);
		
		btnClear = new JButton("CLEAR");
		panel.add(btnClear);
		butgroup[6]=btnClear;
		btnClear.setActionCommand("CLEAR");
		
		btnExit = new JButton("EXIT");
		panel.add(btnExit);
		butgroup[7]=btnExit;
		btnExit.setActionCommand("EXIT");
    
		springLayout.putConstraint(SpringLayout.EAST,this,30,SpringLayout.EAST,tName);
		
		lblSellerid = new JLabel("SELLERID");
		springLayout.putConstraint(SpringLayout.NORTH, lblSellerid, 10, SpringLayout.NORTH, this);
		springLayout.putConstraint(SpringLayout.EAST, lblSellerid, 0, SpringLayout.EAST, tPhone);
		add(lblSellerid);
		
		lblSellerIdlbl = new JLabel("SELLER ID:");
		springLayout.putConstraint(SpringLayout.SOUTH, lblSellerIdlbl, 0, SpringLayout.SOUTH, lblSellerid);
		springLayout.putConstraint(SpringLayout.EAST, lblSellerIdlbl, -45, SpringLayout.WEST, lblSellerid);
		add(lblSellerIdlbl);
		
		lblXyzgmailcom = new JLabel("(Example:xyz123@gmail.com)");
		springLayout.putConstraint(SpringLayout.NORTH, lblXyzgmailcom, 6, SpringLayout.SOUTH, tEmail);
		springLayout.putConstraint(SpringLayout.EAST, lblXyzgmailcom, 0, SpringLayout.EAST, tName);
		add(lblXyzgmailcom);
		
		
	}
	
	
	
	public StringField gettName() {
		return tName;
	}



	public void settName(StringField tName) {
		this.tName = tName;
	}



	public NumericField gettPhone() {
		return tPhone;
	}



	public void settPhone(NumericField tPhone) {
		this.tPhone = tPhone;
	}



	public JTextField gettEmail() {
		return tEmail;
	}



	public void settEmail(JTextField tEmail) {
		this.tEmail = tEmail;
	}



	public JTextArea getTextAreaAdress() {
		return textAreaAdress;
	}



	public void setTextAreaAdress(JTextArea textAreaAdress) {
		this.textAreaAdress = textAreaAdress;
	}



	public JButton getBtnSave() {
		return btnSave;
	}



	public void setBtnSave(JButton btnSave) {
		this.btnSave = btnSave;
	}



	public JButton getBtnDelete() {
		return btnDelete;
	}



	public void setBtnDelete(JButton btnDelete) {
		this.btnDelete = btnDelete;
	}



	public JButton getBtnUpdate() {
		return btnUpdate;
	}



	public void setBtnUpdate(JButton btnUpdate) {
		this.btnUpdate = btnUpdate;
	}



	public JButton getBtnBack() {
		return btnBack;
	}



	public void setBtnBack(JButton btnBack) {
		this.btnBack = btnBack;
	}



	public JButton getBtnSearch() {
		return btnSearch;
	}



	public void setBtnSearch(JButton btnSearch) {
		this.btnSearch = btnSearch;
	}



	public JButton getBtnForward() {
		return btnForward;
	}



	public void setBtnForward(JButton btnForward) {
		this.btnForward = btnForward;
	}



	public JButton getBtnExit() {
		return btnExit;
	}



	public void setBtnExit(JButton btnExit) {
		this.btnExit = btnExit;
	}



	public JButton getBtnClear() {
		return btnClear;
	}



	public void setBtnClear(JButton btnClear) {
		this.btnClear = btnClear;
	}
	
	



	public JLabel getLblSellerid() {
		return lblSellerid;
	}



	public void setLblSellerid(JLabel lblSellerid) {
		this.lblSellerid = lblSellerid;
	}



	public void actionListener(ActionListener al)
	{
		for(int i=0;i<butgroup.length;i++)
		{
			butgroup[i].addActionListener(al);
		}
	}
}
